<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
   	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <link href="<%=request.getContextPath()%>/css/bootstrap.css" rel="stylesheet" type="text/css">
    <script src="<%=request.getContextPath()%>/js/jquery-2.0.3.min.js" type="text/javascript"></script>
    <script src="<%=request.getContextPath()%>/js/bootstrap.js" type="text/javascript"></script>  
    
        
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrapValidator.css"/>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/bootstrapValidator.js"></script>
    
    
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/lhdialog/lhgcore.min.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/lhdialog/lhgdialog.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/OpenDialog.js"></script>
    
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/CheckTheData.js"></script>

	<link href="<%=request.getContextPath() %>/ueditor/themes/default/_css/umeditor.css" type="text/css" rel="stylesheet" />

    <script type="text/javascript" charset="utf-8" src="<%=request.getContextPath() %>/ueditor/umeditor.config.js"></script>
	<script type="text/javascript" charset="utf-8" src="<%=request.getContextPath() %>/ueditor/_examples/editor_api.js"></script>

    <script type="text/javascript">
    
    $(document).ready(function(){
    	//显示商品来源  通过判断哪个为1
    	var infoSource=$("#infoSource").val();
    	var n1='';var n2='';var n3='';var n4='';
    	if(infoSource[0]==1){
        	n1="实体卖场 ";
        }
        if(infoSource[1]==1){
        	n2="中标电商 ";
        }
        if(infoSource[2]==1){
        	n3="其他电商 ";
        }
        if(infoSource[3]==1){
        	n4="政府采购";
        }
    	var newinfoSource=n1+n2+n3+n4;
    	$("#infoSourceShow").val(newinfoSource);
    });
    
    function toShowIntruduction(){
    	//在查看详情tab页面显示详情信息
    	var introductionId=$("#productIntroductionId").val();
      	$.ajax({
         		data:{
    				"id":introductionId
    			},
         		url:"<%=request.getContextPath()%>/product/productIntroduction_showProductIntroduction.action",
         		dataType:"json",
         		success:function(data){
         			 $("#intruductionContent").html(data.content);
         			 $("#intruductionName").val(data.name); 
         		}
         	});
    }
    
    //记录图片框个数
    var picFrameCount = 0;
  
    //删除已选图片
    function deleteChoosePic(id,element){
    	$("#"+id).remove();
    	element.remove();
    }
    
    //显示已选图片
    function showChoosePic(picFrameCount){
    	   var _html ='';
    	   _html += '<div id="picFrameDiv'+picFrameCount+'" class="form-group">';
    	   _html += '    <label class="col-sm-offset-1 col-sm-2 control-label"></label>';
    	   _html += '    <div class="col-sm-2">';
    	   _html += '        <img id="productPicName'+picFrameCount+'" style="padding:2px; border:1px solid; margin-bottom:10px;width:200px;height:200px; ">';
    	   _html += '        <input value="" id="productPicId'+picFrameCount+'" type="hidden" name="productPicIds"'+'>';
    	   _html += '        <div class="check" style="color:#a94442;font-size:85%"><span class="checkMsg"></span></div>';
    	   _html += '    </div>';
    	   _html += '    <div class=" col-sm-1">';
    	   _html += '        <input class="form-control" type="button" value="删除图片" onclick="deleteChoosePic(\'picFrameDiv'+picFrameCount+'\',this)">';
    	   _html += '    </div>';
    	   _html += '</div>';
    	   return _html;
    }
    
    //选择界面（弹出框）
      function choose(entity){
	  	var flag =1;
	  	var pojo=entity;
	  	var page;
	  	if(pojo=='series'){
	  	    page = 	"<%=request.getContextPath()%>/productSeries/ProductSeries_listByPage.action?params=choose&t1.category.id=${t.category.id}";
        }
	  	if(pojo=='productIntroduction'){
	  	    page = 	"<%=request.getContextPath()%>/product/productIntroduction_listByPage.action?params=choose";
        }
	  	if(pojo=='productPic'){
	  	    page = 	"<%=request.getContextPath()%>/productPic/ProductPic_listByPage.action?params=choose&rows=5";
        }
	  	if(pojo=='productAttr'){
	  	    page = 	"<%=request.getContextPath()%>/productAttr/ProductAttr_listByPage.action?params=choose&t1.category.id=${t.category.id}";
        }
	  	
	  	if(flag == 1){
	  		var titleText = "";
	  		PUBLICOBJECT.id = "entid";
	  		PUBLICOBJECT.title = titleText;
	  		PUBLICOBJECT.width = "1000";
	  		PUBLICOBJECT.height = "auto";
	  		PUBLICOBJECT.titleText = titleText;
	  		PUBLICOBJECT.page = page;
	  		var rs = PUBLICOBJECT.openLab();
	  		rs.ShowDialog();// 打开弹出窗
	  		var dom = window.frames["lhgfrm_" + PUBLICOBJECT.id];// 弹出框document对象
	  		rs.addBtn(PUBLICOBJECT.id, "确定", function() {
	  			var _choose = $(dom.document).find("input[name='idChoose']:checked");
	  			var chooseValue = _choose.val();
	  			if(chooseValue != null){
	  				rs.cancel();// 关闭当弹出窗
	  				var chooseName = _choose.siblings("input[name='nameChoose']").val();
	  				if(pojo=='series'){
	  					$("#seriesName").trigger("onchange");
	  			    	$("#seriesId").val(chooseValue);
	  			    	$("#seriesName").val(chooseName);
	  			    	
	  			    	//选择系列后要带出品牌、详情和照片的信息
	  			    	var brandShowName = _choose.siblings("input[name='brandShowChoose']").val();
	  			    	var brandId = _choose.siblings("input[name='brandShowChoose']").attr("id");
	  			    	var introductionName = _choose.siblings("input[name='productIntroductionChoose']").val();
	  			    	var introductionId = _choose.siblings("input[name='productIntroductionChoose']").attr("id");
	  			    	$("#brandShowName").val(brandShowName);
	  			    	$("#brandShowId").val(brandId);
	  			    	$("#productIntroductionName").val(introductionName);
	  			    	$("#productIntroductionId").val(introductionId);
	  			    	
	  			         var srcs=[];
	  			    	var imgIds=[];
	  			    	_choose.siblings("input[name='img']").each(function(){
	  			  	 		 var src=$(this).val();
	  			  	 	     var id=$(this).attr("id");
	  			  	 	     srcs.push(src);
	  			  	 	     imgIds.push(id);
	  			  	 	});
	  			    	
	  			    	$(".img").remove();
	  			    	for(var i=0;i<imgIds.length;i++){
	  			    		var _html=showChoosePic(picFrameCount);
	  			    		$("#choosePicBtnDiv").before(_html);
	  			    		$("#productPicId"+picFrameCount).val(imgIds[i]);
		  			    	$("#productPicName"+picFrameCount).attr("src",srcs[i]);
		  			    	picFrameCount++;
	  			    	}
	  		        }
	  				if(pojo=='productIntroduction'){
	  					$("#productIntroductionName").trigger("onchange");
	  			    	$("#productIntroductionId").val(chooseValue);
	  			    	$("#productIntroductionName").val(chooseName);
	  		        }
	  				if(pojo=='productPic'){
	  			    	var _html=showChoosePic(picFrameCount);
	  					$("#choosePicBtnDiv").before(_html);
	  			    	$("#productPicId"+picFrameCount).val(chooseValue);
	  			    	$("#productPicName"+picFrameCount).attr("src",chooseName);
	  			    	picFrameCount++;
	  		        }
	  				if(pojo=='productAttr'){
	  					$("#productAttrName").trigger("onchange");
	  			    	$("#productAttrId").val(chooseValue);
	  			    	$("#productAttrName").val(chooseName);
	  				}
	  			}else{
	  				alert("请选择一项");
	  			}
	  		}, "left");
	  	}
    }

    //每一步的保存操作
  	function submitForm(i){
  		if(i==1){//保存商品的基本信息
  			checkString("name","商品名称不能为空"); 
  	 	    checkString("model","商品型号不能为空");
  	 	    checkString("categoryName","类别名称不能为空");
  	 	    checkString("seriesName","系列名称不能为空");
  	 	    checkString("brandShowName","品牌名称不能为空");
  	 	    checkString("productIntroductionName","商品详情不能为空");
  	 	    
  	 	    
  	        if(checkString("name","商品名称不能为空") 
  	  		&& checkString("model","商品型号不能为空")
  	  		&& checkString("categoryName","类别名称不能为空")
  	  		&& checkString("seriesName","系列名称不能为空")
  	  		&& checkString("brandShowName","品牌名称不能为空")
  	  		&& checkString("productIntroductionName","商品详情不能为空")
  	  		){ 
  	  			var pid=$("#productId").val().trim();
  	  			
  	  		    var productPicIds=new Array();
		  	 	$("input[name='productPicIds']").each(function(){
		  	 		 var id=$(this).val();
		  	 		productPicIds.push(id);
		  	 	});
  	  		
  	  			$.ajax({
  	  				type:"post",
  	  				dataType:"json",
  	  				cache:false,
  	  				async:false,
  	  			    traditional: true,
  	  				data:{
  	  				    "t.status":$("#status").val(),
  	  				    "t.creator":$("#creator").val(),
  	  			        "t.creationTime":$("#creationTime").val(),
  	  			        "t.sku":$("#sku").val(),
  	  			        
  	  			        "productPicIds":productPicIds,
  	  					"t.id":pid,
  	  					"t.name":$("#name").val(),
  	  				    "t.model":$("#model").val(),
  	  					"t.infoSource":$("#infoSource").val(),
  	  					"t.category.id":$("#categoryId").val(),
  	  					"t.productSeries.id":$("#seriesId").val(),
  	  					"t.brandShow.id":$("#brandShowId").val(),
  	  					//"t.productPic.id":$("#productPicId").val(),
  	  					"t.productIntroduction.id":$("#productIntroductionId").val()
  	  				},
  	  				url:'<%=request.getContextPath()%>/productMain/Product_saveProduct.action',
  	  				success:function(data){
  	  					alert(data.message);
  	  				    //var productId=data.object;
  	  				    if(data.object!==null){
	  	  				    $("#productId").val(data.object[0]);
		  	  				$("#status").val(data.object[1]);
			  	  			$("#creator").val(data.object[2]);
			  	  			$("#creationTime").val(data.object[3]);
			  	  		    $("#sku").val(data.object[4]);
  	  				    }
  	  				}
  	  		   });
  		    }
        }else if(i==2){//保存商品的属性信息
        	
        	var pid=$("#productId").val().trim();
    		var data0 = $("#productAttrValueMng").serialize();
    		$.ajax({
    			data:{
    				//"t1.product.id":pid
    				"pId":pid
    			},
    			url:"<%=request.getContextPath()%>/productAttrValue/ProductAttrValue_saveProductAttrValue.action?"+data0,
    			dataType:"json",
    			success:function(value){
    				if(value.success==true){
    					alert(value.message);
    					
    					var attrValueIdList=value.object;
    					var productAttrValueIds=new Array();
    					$("input[name='productAttrValueId']").each(function(){
							 var id=$(this).val();
							 productAttrValueIds.push(id);
						});
    					
    					for(var i=0;i<attrValueIdList.length;i++){
    						$("input[name='productAttrValueId']:eq("+i+")").val(attrValueIdList[i]);
    					}
    				}else{
    					alert(value.message);
    				}
    			}
    			
    		});
        }else if(i==3){//保存商品的价格信息
        	<%-- //提交修改
        	var pid=$("#productId").val().trim();
        		var data0 = $("#productPriceMng").serialize();
        		$.ajax({
        			data:{
        				"t1.product.id":pid
        			},
        			url:"<%=request.getContextPath()%>/productMain/ProductPrice_updateProductPrice.action?"+data0,
        			dataType:"json",
        			success:function(value){
        				if(value.success==true){
        					alert(value.message);
        				}else{
        					alert(value.message);
        				}
        			}
        			
        		}); --%>
        }
  		
  	}
    
    //下一步
  	function nextPage(i){
    	if(i==2){
    	   if(checkString("name","商品名称不能为空") 
	  	  		&& checkString("model","商品型号不能为空")
	  	  		&& checkString("categoryName","类别名称不能为空")
	  	  		&& checkString("seriesName","系列名称不能为空")
	  	  		&& checkString("brandShowName","品牌名称不能为空")
	  	  		&& checkString("productIntroductionName","商品详情不能为空")
	  	  	){
    			if(checkString("productId")){
    			   $('#myTab a[href="#attr"]').show();
	    	       $('#myTab a[href="#attr"]').tab('show');
    			}else{
    				alert("请保存商品信息")
    			}
    		}else{
    			alert("请填写信息")
    		} 
    	}
    }  
    </script>
</head>

<body>
<div class="panel panel-primary">
    <div class="panel-heading">商品管理</div>
    <div class="panel-body"> 
		<!-- Nav tabs -->
		<c:if test="${empty method }">
		<ul class="nav nav-tabs" role="tablist" id="myTab">
		  <li role="presentation" class="active"><a href="#basic" role="tab" data-toggle="tab">基本信息</a></li>
		  <li role="presentation"><a href="#introduction" role="tab" data-toggle="tab" onclick="toShowIntruduction()">查看详情信息</a></li>
		  <li role="presentation"><a href="#attr" role="tab" data-toggle="tab" style="display:none">商品属性</a></li>
		  <!-- <li role="presentation"><a href="#price" role="tab" data-toggle="tab" style="display:none">商品价格</a></li> -->
		</ul>
		</c:if>
		<c:if test="${!empty method }">
		<ul class="nav nav-tabs" role="tablist" id="myTab">
		  <li role="presentation" class="active"><a href="#basic" role="tab" data-toggle="tab">基本信息</a></li>
		  <li role="presentation"><a href="#introduction" role="tab" data-toggle="tab" onclick="toShowIntruduction()">查看详情信息</a></li>
		  <li role="presentation"><a href="#attr" role="tab" data-toggle="tab">商品属性</a></li>
		  <li role="presentation"><a href="#price" role="tab" data-toggle="tab">商品价格</a></li>
		</ul>
		</c:if>
	 	
		<!-- Tab panes begin -->
		<div class="tab-content">
		
		
		  <!-- 基本信息开始 -->
		  <div role="tabpanel" class="tab-pane active" id="basic">
		      <input type="hidden" value="${method }" name="method" id="method"/>
		      <input type="hidden"   value="1" id="flag" name="flag"/>
		      <%@include file="productDataInfo.jsp" %>
		  </div>
		  <!-- 基本信息结束 -->
		  
		   <!-- 查看详情信息开始 -->
		  <div role="tabpanel" class="tab-pane" id="introduction">
		      <div class="panel-body"> 
				  <form class="form-horizontal" action="" method="post">
					      
				      <div class="form-group">
						  <label class="col-sm-offset-1 col-sm-2 control-label">详情名称：</label>
						  <div class="col-sm-2">
						       <input class="form-control" type="text" readonly="readonly" id="intruductionName" value=""> 
						  </div>
					  </div>
					  <div class="form-group">
						  <label class="col-sm-offset-1 col-sm-2 control-label">详情内容：</label>
						  <div class="col-sm-5">
						        <br/>
                                <div id="intruductionContent"/>
						  </div>
						  </div>
					  </div>
					
					</form>
				</div>
		  </div>
		  <!-- 查看详情信息结束 -->
		  
		  <!-- 属性信息开始 -->
		  <div role="tabpanel" class="tab-pane" id="attr">
		      <%@include file="productDataAttrValue.jsp" %>
		  </div>
		  <!-- 属性信息结束 -->
		  
		  <!-- 商品价格开始 -->
		  <div role="tabpanel" class="tab-pane" id="price">
		      <%@include file='productDataPrice.jsp' %>
		  </div>
		  <!-- 商品价格结束 -->
		  
		</div>
		<!-- Tab panes end -->
   
   </div>
     
</div>

<c:if test="${!empty method }">
<div class="row">
    <div class="col-sm-offset-5 col-sm-2">
		<input type="button" class="btn btn-default" onclick="JavaScript:history.go(-1)" value="返回商品列表">
    </div>
</div>
</c:if>






<script type="text/javascript">
/*
 * 以下都是关于价格的js-------------------------------------------------------------------------
 */
 <%-- //提交修改  
 var pid=$("#productId").val().trim();
 
 var ids=new Array();
	$("input[name='id']").each(function(){
		 var id=$(this).val();
		 ids.push(id);
	});
 
 var prices=new Array();
	$("input[name='price1']").each(function(){
		 var price=$(this).val();
		 prices.push(price);
	});
	
 var types=new Array();
	$("select[name='type1']").each(function(){
		 var type=$(this).val();
	     types.push(type);
	});
	
 if(pid!=null && pid!=""){
			$.ajax({
				type:"post",
				dataType:"json",
				cache:false,
				async:false,
			    traditional: true,//加上这个就相当于price=11&price=22
				data:{
					"price":prices,
					"type":types,
					"pId":pid
				},
				url:'<%=request.getContextPath()%>/productMain/ProductPrice_saveProductPrice.action',
				success:function(data){
					alert(data.message);
					$("div[name='addDiv']").each(function(){
						$(this).remove();
					});
					
					
				    $("div[name='iDiv']").each(function(){
						$(this).remove();
					});
				
					 for(var i=0;i<data.object.length;i++){
					    var _html ="";
	  				    _html += "<div class='form-group' name='iDiv' id='Div"+i+"'>";
	  					_html += "    <label for='type' class='col-sm-offset-1 col-sm-2 control-label'>价格类型：</label>";
	  					_html += "    <div class='col-sm-2'>";
	  					_html += "        <input type='text' class='form-control' readonly='readonly' value='";
	  					if(data.object[i].type==1){
	  			  	    	_html += "最低价";
	  			  	    }
	  			  	    if(data.object[i].type==2){
	  				    	_html += "最高价";
	  				    }
	  			   	    if(data.object[i].type==3){
	  				    	_html += "畅销价";
	  				    }
	  					_html += "        '>";
	  				    _html += "    </div>";
	  							    
	  				    _html += "    <label for='price' class='col-sm-2 control-label'>商品价格：</label>";
	  				    _html += "    <div class='col-sm-2'>";
	  				    _html += "        <input type='text' class='form-control' readonly='readonly' value='"+data.object[i].price+"'>";
	  				    _html += "    </div>";
	  				    
	  				   	_html += "    <div class='col-sm-2'>";
	  				    _html += "        <input type='button' class='btn btn-default' onclick='editPrice("+data.object[i].id+","+data.object[i].type+","+data.object[i].price+",\"Div"+i+"\")' value='编辑'>";
	  				   	_html += "        <input type='button' class='btn btn-default' onclick='deletePrice(this,"+data.object[i].id+")' value='删除'>";
	  				   	_html += "    </div>"; 
	  				   $("#addButton").before(_html);  
	  				   $("#saveId").hide();
					}
				}
		   });
 }else{
 	alert("请先填写商品价格的信息")
 } --%>
 
 
 
 
<%-- 
  	//添加价格
  	function addPrice(buttonObj){
  		if(check()){
  			$("#saveId").show();
  			var num = $("#num").val();
  			num =parseFloat(num)+1;
  			$("#num").val(num);
  			var pricehtml = "";

  			pricehtml += "<div class='form-group' name='addDiv'>";
  			pricehtml += "     <label for='type' class='col-sm-offset-1 col-sm-2 control-label'>价格类型：</label>";
  			pricehtml += "		    <div class='col-sm-2'>";
  			pricehtml += "		        <select name='type1'  class='form-control'>";
  			pricehtml += "			            <option value=''>请选择价格类型</option>";
  			pricehtml += "			            <option value='1'>最低价</option>";
  			pricehtml += "			            <option value='2'>最高价</option>";
  			pricehtml += "			            <option value='3'>畅销价</option>";
  			pricehtml += "		        </select>";
  			pricehtml += "	    </div>";
					    
  			pricehtml += "	    <label for='price' class='col-sm-2 control-label'>商品价格：</label>";
  			pricehtml += "	    <div class='col-sm-2'>";
  			pricehtml += "			<input type='text' name='price1' class='form-control' id='price' placeholder='请输入商品价格'>";
  			pricehtml += "	    </div>";
					    
  			pricehtml += "	    <div class='col-sm-2'>";
  			pricehtml += "		    <input type='button' class='btn btn-default' onclick='deleteTr(this)' value='删除'>";
  			pricehtml += "	    </div>";
  			pricehtml += "  </div>";
  			
  		    $("#addButton").before(pricehtml);  
  		}
  	}
  	
  //校验--有在编辑的价格时，不能添加新价格和保存其他价格
  	function checkEdit(){
  		var submitFlag = true; 
  		var flag = $("#flag").val();
  		if(flag == 1 ){
  			submitFlag = true;
  		}else if (flag == '0'){
  			alert('请先保存正在编辑的价格');
  			submitFlag = false;
  		}
  		return submitFlag;
  	}
  
  //保存--校验所有信息不为空
  	function check() {
  		if(checkEdit()){
  			var flag = true;
  			$("input[name='price']").each(
  				function() {
  					if($(this).val()==''){
  						flag =false;
  						alert('请填写商品价格 ');
  					}
  				}
  			);
  			$("input[name='type']").each(
  	  				function() {
  	  					if($(this).val()==''){
  	  						flag =false;
  	  						alert('请填写商品价格 ');
  	  					}
  	  				}
  	  			);
  			return flag;
  		}
  	}
  
  	
  //删除没有保存到数据库的价格
  	function deleteTr(obj){
  		if(confirm('是否删除')){
  		 $(obj).parent().parent().remove();
  		}
  	}
  
  //删除价格
  	function deletePrice(obj,id){
  		if(confirm('确定是否删除？')){
  			$("#flag").val("1");
  			var id=id;
  			$.ajax({
	  				type:"post",
	  				dataType:"json",
	  				data:{
	  					"id":id
	  				},
	  				url:'<%=request.getContextPath()%>/productMain/ProductPrice_deletePrice.action',
	  				success:function(data){
	  					$(obj).parent().parent().remove();
	  					alert(data.message);
	  				}
	  		   });
  			
  		}
  	}
  
  //编辑价格时
  	function editPrice(id,type,price,trId){
  		//$("#flag").val("0");
  		var num = $("#num").val();
  		num =parseFloat(num)+1;
  		$("#num").val(num);
  		
  		//点击编辑后   由只读的变为可修改的  将原有的div制空  在原有div前添加新的div进行修改
  		$("#"+trId).html("");
  		var _html = "";
  		_html += "<div class='form-group' id='eidtDiv"+num+"'>";
  		_html += "    <input type='hidden' name='id' id='id"+num+"' value='"+id+"'>";

  		_html += "    <label for='type' class='col-sm-offset-1 col-sm-2 control-label'>价格类型：</label>";
  		_html += "    <div class='col-sm-2'>";
  		_html += "        <select name='type' id='type"+num+"'  class='form-control'>";
  	    _html += "	            <option value='"+type+"'>";
  	    if(type==1){
  	    	_html += "           最低价";
  	    }
  	    if(type==2){
	    	_html += "           最高价";
	    }
   	    if(type==3){
	    	_html += "           畅销价";
	    }
  	    
  	    _html += "	            </option>";
  	   	_html += "	    </select>";
  	    _html += "    </div>";
  					    
  		_html += "    <label for='price' class='col-sm-2 control-label'>商品价格：</label>";
  		_html += "    <div class='col-sm-2'>";
  		_html += "		  <input type='text' name='price' id='price"+num+"' class='form-control' id='price' placeholder='请输入商品价格' value='"+price+"'>";
  		_html += "    </div>";
  		    
  		_html += "    <div class='col-sm-2'>";
  		_html += "        <input type='button' class='btn btn-default' onclick='saveTr("+id+","+num+",\""+trId+"\")' value='保存'>";
  		_html += "        <input type='button' class='btn btn-default' onclick='deletePrice(this,"+id+")' value='删除'>";
  		_html += "    </div>";
  		_html += "</div>";
  	    $("#"+trId).before(_html);  
  	}
  
    //保存编辑的价格
  	function saveTr(id,num,trId){
  		if(confirm('是否确定保存该价格？')){
  			//$("#flag").val("1");
  			var productId = $("#productId").val();
  			var price = $("#price"+num).val();
  			var type = $("#type"+num).val();
  			$.ajax({
  				    type:"post",
	  				dataType:"json",
	  				cache:false,
	  				async:false,
	  				data:{
	  					"t.id":id,
	  					"t.price":price,
  					    "t.type":type,
	  					"t.product.id":productId
	  				},
	  				url:'<%=request.getContextPath()%>/productMain/ProductPrice_updateProductPrice.action',
	  				success:function(data){
	  					alert(data.message);
	  					
	  					
	  					//修改成功后  将新的div删除  并将原有div修改未只读的
	  					$("#eidtDiv"+num).remove();
	  					
	  					var _html ="";
	  					_html += "    <label for='type' class='col-sm-offset-1 col-sm-2 control-label'>价格类型：</label>";
	  					_html += "    <div class='col-sm-2'>";
	  					_html += "        <input type='text' class='form-control' readonly='readonly' value='";
	  					if(type==1){
	  			  	    	_html += "最低价";
	  			  	    }
	  			  	    if(type==2){
	  				    	_html += "最高价";
	  				    }
	  			   	    if(type==3){
	  				    	_html += "畅销价";
	  				    }
	  					_html += "        '>";
	  				    _html += "    </div>";
	  							    
	  				    _html += "    <label for='price' class='col-sm-2 control-label'>商品价格：</label>";
	  				    _html += "    <div class='col-sm-2'>";
	  				    _html += "        <input type='text' class='form-control' readonly='readonly' value='"+price+"'>";
	  				    _html += "    </div>";
	  				    
	  				   	_html += "    <div class='col-sm-2'>";
	  				    _html += "        <input type='button' class='btn btn-default' onclick='editPrice("+id+","+type+","+price+",\""+trId+"\")' value='编辑'>";
	  				   	_html += "        <input type='button' class='btn btn-default' onclick='deletePrice(this,'"+id+"')' value='删除'>";
	  				   	_html += "    </div>";
	  					$("#"+trId).html(_html);
	  				}
  			});
  		}
  	} --%>
</script>
</body>
</html>
